package com.tangji.signaltower;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.TimeZone;

/**
 * Created with IntelliJ IDEA.
 * User: yujianfu (mr.vencnet@gmail.com)
 * Date: 2017/7/20
 * Time: 上午10:30
 */
@SpringBootApplication
@ComponentScan(basePackages = {
        "com.tangji.signaltower", "com.tangji.antenna"
})
@ImportResource({
        "classpath:config.xml"
})
@EnableScheduling
@EnableAsync
public class SignalTowerApplication {
    private static final Logger logger = LoggerFactory.getLogger(SignalTowerApplication.class);

    public static void main(String[] args) {
        TimeZone.setDefault(TimeZone.getTimeZone("Asia/Calcutta"));
        ApplicationContext context = SpringApplication.run(SignalTowerApplication.class, args);

        Environment env = context.getEnvironment();
        String host = null;
        try {
            host = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
        }
        String port = env.getProperty("server.port");

        logger.info("signal tower 启动成功! 示例页面点击进入: http://" + host + ":" + port + "");

    }
}
